﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace W.Models.Utils
{
    public static class Merge<T>
    {
        public static T Copy(ref T Destinatary, T Entity)
        {
            PropertyInfo[] Properties = Entity.GetType().GetProperties();

            foreach (PropertyInfo Property in Properties)
            {
                if (!Property.GetType().IsClass || Property.GetType() == typeof(String))
                    Property.SetValue(Destinatary, Property.GetValue(Entity, null), null);
            }

            return Destinatary;
        }
    }
}
